var cc__decorate = __decorate;
Object.defineProperty(exports, "__esModule", {
  value: true
});
var $2gameBefore = require("gameBefore");
var $2ConstValue = require("ConstValue");
var $2GameUser = require("GameUser");
var $2UIManager = require("UIManager");
var $2Platformconf = require("Platformconf");
var $2PlatformMgr = require("PlatformMgr");
var $2BaseUIPopup = require("BaseUIPopup");
var $2UIVMain = require("UIVMain");
var cc__decorator = cc._decorator;
var ccp_ccclass = cc__decorator.ccclass;
var ccp_property = cc__decorator.property;
var def_UIPskin = /* */function (_d$default) {
  function _ctor() {
    var _this127;
    babel_classCallCheck(this, _ctor);
    _this127 = _callSuper(this, _ctor, arguments);
    _this127.root = null;
    _this127.root2 = null;
    _this127.root3 = null;
    _this127.skinType = "a";
    _this127.eType = ["a", "b", "c"];
    _this127.scroller_arr = [];
    return _this127;
  }
  babel_inherits(_ctor, _d$default);
  return babel_createClass(_ctor, [{
    key: "onShow",
    value: function onShow() {
      babel_get(babel_getPrototypeOf(_ctor.prototype), "onShow", this).call(this);
      this.init();
      $2Platformconf.default.PlatformType === $2Platformconf.ePlatformType.WXGame && cc.Canvas.instance.node.getComponent($2gameBefore.default).BannerShow();
      if ($2ConstValue.ConstValue.PlayerOnLineTime >= 60) {
        if ($2Platformconf.default.PlatformType === $2Platformconf.ePlatformType.TTGame) {
          $2ConstValue.ConstValue.InterAdIntervalTime <= 0 && $2PlatformMgr.default.Instance().interstitialShow(0);
        } else {
          $2Platformconf.default.PlatformType === $2Platformconf.ePlatformType.KWaiGame && $2ConstValue.ConstValue.InterAdIntervalTime <= 0 && $2PlatformMgr.default.Instance().interstitialShow(0);
        }
      }
      $2Platformconf.default.PlatformType === $2Platformconf.ePlatformType.WXGame && $2PlatformMgr.default.Instance().interstitialShow(0);
      null != $2UIManager.UIManager.getInstance().getUI($2UIVMain.default) && $2UIManager.UIManager.getInstance().getUI($2UIVMain.default).hideYXQ();
    }
  }, {
    key: "btn",
    value: function btn(e) {
      babel_get(babel_getPrototypeOf(_ctor.prototype), "click", this).call(this, e, null);
      var t = e.node.name;
      this.changetype(t);
    }
  }, {
    key: "changetype",
    value: function changetype(e) {
      if (this.skinType == e) {
        return;
      }
      this.skinType = e;
      var t = this.eType.indexOf(e);
      for (var _n60 = 0; _n60 < this.scroller_arr.length; _n60++) {
        this.scroller_arr[_n60].active = _n60 == t;
      }
    }
  }, {
    key: "click",
    value: function click(e, t) {
      var _this128 = this;
      babel_get(babel_getPrototypeOf(_ctor.prototype), "click", this).call(this, e, t);
      var n = e.getCurrentTarget();
      if ("close" == t) {
        null != $2UIManager.UIManager.getInstance().getUI($2UIVMain.default) && $2UIManager.UIManager.getInstance().getUI($2UIVMain.default).showYXQ();
        this.close();
      } else if ("unlock" == n.name) {
        var _e73 = n.parent.name;
        console.log("unlock", _e73);
        $2UIManager.UIManager.getInstance().getUI($2UIVMain.default).levelPlayAD(function (t) {
          if (true === t) {
            if ("a" == _this128.skinType) {
              $2GameUser.default.getInstance().setUnlockSkin(_e73, true), n.active = false, n.parent.getChildByName("choose").active = true;
            } else if ("b" == _this128.skinType) {
              $2GameUser.default.getInstance().setUnlockSkin_stone(_e73, true), n.active = false, n.parent.getChildByName("choose").active = true;
            } else {
              "c" == _this128.skinType && ($2GameUser.default.getInstance().setUnlockSkin_spine(_e73, true), n.active = false, n.parent.getChildByName("choose").active = true);
            }
            cc.director.resume();
          }
        }, function () {
          cc.director.resume();
        });
      } else if ("choose" == n.name) {
        var _e74 = n.parent.name;
        n.active = false;
        n.parent.getChildByName("useing").active = true;
        if ("a" == this.skinType) {
          var _t64 = $2GameUser.default.getInstance().curr_skin;
          var _n61 = this.root.getChildByName(_t64);
          _n61.getChildByName("useing").active = false;
          _n61.getChildByName("choose").active = true;
          $2GameUser.default.getInstance().curr_skin = _e74;
        } else if ("b" == this.skinType) {
          var _t65 = $2GameUser.default.getInstance().curr_skin_stone;
          var _n62 = this.root2.getChildByName(_t65);
          _n62.getChildByName("useing").active = false;
          _n62.getChildByName("choose").active = true;
          $2GameUser.default.getInstance().curr_skin_stone = _e74;
        } else if ("c" == this.skinType) {
          var _t66 = $2GameUser.default.getInstance().curr_skin_spine;
          var _n63 = this.root3.getChildByName(_t66);
          _n63.getChildByName("useing").active = false;
          _n63.getChildByName("choose").active = true;
          $2GameUser.default.getInstance().curr_skin_spine = _e74;
          $2UIManager.UIManager.getInstance().getUI($2UIVMain.default).set_hero();
        }
      }
    }
  }, {
    key: "init",
    value: function init() {
      var _this129 = this;
      var e = $2GameUser.default.getInstance().curr_skin;
      for (var _t67 = 0; _t67 < this.root.childrenCount - 1; _t67++) {
        var _n64 = "".concat(_t67);
        var _o126 = $2GameUser.default.getInstance().getUnlockSkin(_n64);
        var _i30 = this.root.getChildByName(_n64);
        if ("0" == _n64) {
          _i30.getChildByName("choose").active = e != _n64;
          _i30.getChildByName("useing").active = e == _n64;
        } else {
          _i30.getChildByName("unlock").active = !_o126;
          _i30.getChildByName("choose").active = _o126 && e != _n64;
          _i30.getChildByName("useing").active = _o126 && e == _n64;
        }
      }
      this.scheduleOnce(function () {
        var e = $2GameUser.default.getInstance().curr_skin_stone;
        for (var _t68 = 0; _t68 < _this129.root2.childrenCount - 1; _t68++) {
          var _n65 = "".concat(_t68);
          var _o127 = $2GameUser.default.getInstance().getUnlockSkin_stone(_n65);
          var _i31 = _this129.root2.getChildByName(_n65);
          if ("0" == _n65) {
            _i31.getChildByName("choose").active = e != _n65;
            _i31.getChildByName("useing").active = e == _n65;
          } else {
            _i31.getChildByName("unlock").active = !_o127;
            _i31.getChildByName("choose").active = _o127 && e != _n65;
            _i31.getChildByName("useing").active = _o127 && e == _n65;
          }
        }
        _this129.scheduleOnce(function () {
          var e = $2GameUser.default.getInstance().curr_skin_spine;
          for (var _t69 = 0; _t69 < _this129.root3.childrenCount - 1; _t69++) {
            var _n66 = "".concat(_t69);
            var _o128 = $2GameUser.default.getInstance().getUnlockSkin_spine(_n66);
            var _i32 = _this129.root3.getChildByName(_n66);
            if ("0" == _n66) {
              _i32.getChildByName("choose").active = e != _n66;
              _i32.getChildByName("useing").active = e == _n66;
            } else {
              _i32.getChildByName("unlock").active = !_o128;
              _i32.getChildByName("choose").active = _o128 && e != _n66;
              _i32.getChildByName("useing").active = _o128 && e == _n66;
            }
          }
        });
      });
      this.scroller_arr[0].active = true;
      this.scroller_arr[1].active = false;
      this.scroller_arr[2].active = false;
    }
  }]);
}($2BaseUIPopup.default);
def_UIPskin.className = "UIPskin";
cc__decorate([ccp_property(cc.Node)], def_UIPskin.prototype, "root", undefined);
cc__decorate([ccp_property(cc.Node)], def_UIPskin.prototype, "root2", undefined);
cc__decorate([ccp_property(cc.Node)], def_UIPskin.prototype, "root3", undefined);
cc__decorate([ccp_property(cc.Node)], def_UIPskin.prototype, "scroller_arr", undefined);
def_UIPskin = cc__decorate([ccp_ccclass], def_UIPskin);
exports.default = def_UIPskin;